package com.example.cookbook.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

import com.example.cookbook.R;
import com.example.cookbook.bean.YlBean;

public class YlAdapter extends RecyclerView.Adapter<YlAdapter.ViewHolder> {
    private List<YlBean> mYLlist;
    private Context homecontext;
    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView i_nameyl,i_unityl;
        public ViewHolder(View view){
            super(view);
            i_nameyl = view.findViewById(R.id.i_ylname);
            i_unityl = view.findViewById(R.id.i_ylUnit);
        }
    }
    public YlAdapter(Context context,List<YlBean> YLlist){
        homecontext = context;
        mYLlist = YLlist;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int i) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recy_item_yl,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        YlBean ylBean = mYLlist.get(position);
        holder.i_nameyl.setText(ylBean.getYlName());
        holder.i_unityl.setText(ylBean.getYlUnit());
    }
    @Override
    public int getItemCount() {
        return mYLlist.size();
    }

}